﻿'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {};
modelField.Code = {
    type: String,
    Name: '编码',
    IsUnique: true,
    IsEmpty: false,
    trim: true
};
modelField.Name = {
    type: String,
    Name: '名称',
    IsEmpty: false,
    trim: true
};

modelField.ItemMaster = {
    type: Schema.ObjectId,
    ref: 'ItemMaster'
};

//料品分类
modelField.ItemCategory = {
    type: Number
};
modelField.ErpId = {
    type: String,
    trim: true
};
modelField.IsEffective = {
    type: Boolean
};
modelField.Remark = {
    type: String,
    default: '',
    trim: true
};

var newModel = new Model(modelField);
newModel.addIndex({Code: 1});
newModel.addIndex({ItemMaster: 1, ItemCategory: 1}, {"unique": true});
newModel.addIndex({ItemMaster: 1});

newModel.create('Routing', '工艺路线');